#ifndef _MEDIATOR_
#define _MEDIATOR_

#include <semaphore.h>

#define MAX_BREAKPOINT_DATA		64
#define MAX_BREAKPOINT_NUM		64
#define MAX_BREAKPOINT_QUEUE	16
#define MAX_BREAKPOINT_DEL		16
#define MAX_MEMORY_DUMP_QUEUE	64

struct plugin_list {
	int plugin_id;
	struct plugin_list *next;
};

struct break_point {
	int index;
	int type, data_size;
	char buf[MAX_BREAKPOINT_DATA];
	struct plugin_list *handler;
};

struct break_point_del {
	int index;
	int plugin_id;
};

struct memory_dump {
	unsigned int addr;
	void *data;
	int size;
	int plugin_id;
};

// Interfaces for chipmuck
int mediator_listen();
void mediator_work();
void mediator_stop();

// Interfaces for plugin
int mediator_add_breakpoint(int type, const void *data, int len, int plugin_id);
int mediator_dump_memory(unsigned int addr, void *data, int size, int plugin_id);
int mediator_del_breakpoint(int index, int plugin_id);

extern sem_t simulator_free;
extern int bpnum, bpqueuenum, bpdelnum, mdnum;
extern struct break_point bplist[MAX_BREAKPOINT_NUM], bpqueue[MAX_BREAKPOINT_QUEUE];
extern struct break_point_del bpdelqueue[MAX_BREAKPOINT_DEL];
extern struct memory_dump mdlist[MAX_MEMORY_DUMP_QUEUE];

#endif
